﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ledict.ConditionExtract.Base;
using Ledict.ConditionExtract.BLL;
using Ledict.ConditionExtract.Model;

namespace Ledict.ConditionExtract.Frm.NodeTree
{
    /// <summary>
    /// 诉请种类修改窗口
    /// </summary>
    public partial class FrmEditSutiType : BaseForm
    {
        readonly NodeTree_ArgumentTypeBLL nodetree_argumenttypebll = new NodeTree_ArgumentTypeBLL();
        SYS_ArgumentType _sysArgumentType;
        /// <summary>
        ///  情形情节ID
        /// </summary>
        public string CcId { get; set; }

        public FrmEditSutiType()
        {
            InitializeComponent();

        }

        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmEditSutiType_Load(object sender, EventArgs e)
        {
            ShowMatchKeyWord();
        }

        /// <summary>
        /// 显示诉请种类
        /// </summary>
        public void ShowMatchKeyWord()
        {

            ArgumentTypeXmlBLL Arbll = new ArgumentTypeXmlBLL();
            _sysArgumentType = Arbll.Get_AT_MatchKeyWordBll(CcId);
            txtMatchKeyWord.Text = _sysArgumentType.AT_MatchKeyWord.Replace(";", ";\r\n").Replace("；", "；\r\n"); ;
            //dt.DefaultView.Sort = "SuitTypecode desc";
            //foreach (var item in dt.Rows)
            //{
            //    string str1 = ((DataRow)item)[2].ToString();
            //    string str2 = ((DataRow)item)[3].ToString();
            //    txtMatchKeyWord.Text += str1 + "=" + str2 + ";\r\n";
            //}
            //Arbll.Relation_GetReg_EI_Code_Sql()

            //if (string.IsNullOrEmpty(CcId))
            //    return;

            //有字典值的显示
            //var matchValueCode = nodetree_argumenttypebll.IsExistMatchKeyWordCode(CcId);
            //var model = nodetree_argumenttypebll.GetMatchKeyWord(matchValueCode);
            //if (model != null)
            //    txtMatchKeyWord.Text = model.AT_MatchKeyWord.Replace(";", ";\r\n").Replace("；", "；\r\n");


        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                _sysArgumentType.AT_MatchKeyWord = txtMatchKeyWord.Text;
                nodetree_argumenttypebll.Update(_sysArgumentType, CcId);
                //GV_ArgumentType.Rows[RowIndex].Cells["AT_MatchKeyWord"].Value = MatchKeyWordText.Text.Replace("\n", "");
                MessageBox.Show("修改文本成功！");

                //ShowMatchKeyWord();
                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception error)
            {
                MessageBox.Show("修改文本失败！" + error);
            }
        }

    }
}
